package com.huanong.it.xwuser.authority.domain.model;

import com.huanong.it.xwuser.authority.domain.User;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
public class LoginUser implements UserDetails {

    private static final long serialVersionUID = 1L;

    /**
     * 用户信息
     */
    private User user;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return user.getAuthorities();
    }

    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public String getUsername() {
        return user.getUsername();
    }

    @Override
    public boolean isAccountNonExpired() {
        return user.getStatu()==0||user.getStatu()==null;
    }

    @Override
    public boolean isAccountNonLocked() {
        return user.getStatu()==0||user.getStatu()==null;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return user.getStatu()==0||user.getStatu()==null;
    }

    @Override
    public boolean isEnabled() {
        return user.getStatu()==0||user.getStatu()==null;
    }
}

